#include <stdio.h>
#include <string.h>

int get_cmd_result(const char *command, char *result, int slen)
{
	int nRet = 0;
	FILE *file;
	file = popen(command, "r");
	if(file){
		strcpy(result, "");
		char line[1024];
		while(fgets(line, sizeof(line), file)){
			strncat(result, line, slen);
		}
		pclose(file);
	}
	else{
		nRet = -1;
	}
	return nRet;
}

